#pragma once

#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "type.h"
#include <vector>
#include <memory>

enum class SymbolKind
{
    LocalVariable
};

class Symbol
{
public:
    Symbol(SymbolKind kind, CType* ty, llvm::StringRef name): kind(kind), ty(ty), name(name) {}   
    CType* getTy() { return ty; } 
private:
    SymbolKind kind;
    CType* ty;
    llvm::StringRef name;
};

class Env
{
public:
    llvm::StringMap<std::shared_ptr<Symbol>> VariableSymbolTable;
};

class Scope
{
public:
    Scope();
    void EnterScope();
    void ExitScope();
    void AddVarSymbol(SymbolKind kind, CType* ty, llvm::StringRef name);
    std::shared_ptr<Symbol> FindVarSymbol(llvm::StringRef name);
    std::shared_ptr<Symbol> FindVarSymbolInCurEnv(llvm::StringRef name);

private:
    std::vector<std::shared_ptr<Env>> Envs; 
};